<template>
    <div id="hourGuanLi">
        <!--        搜索表单-->
        <el-form :inline="true" :model="SearchForm" class="demo-form-inline" style="height: 50px">
            <el-form-item >
                <el-input v-model="SearchForm.goodsname" placeholder="商品名称"></el-input>
            </el-form-item>
            <el-form-item>
                <el-date-picker
                        v-model="SearchForm.beginTime"
                        type="date"
                        placeholder="选择创建日期">
                </el-date-picker>
                ——
                <el-date-picker
                        v-model="SearchForm.endTime"
                        type="date"
                        placeholder="选择结束日期">
                </el-date-picker>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="initTable()">查询</el-button>
            </el-form-item>
        </el-form>
        <!--        表格回显-->
        <el-table
                :data="tableData"
                border
                style="width: 100%">
            <el-table-column
                    prop="soid"
                    label="订单编号">
            </el-table-column>
            <el-table-column
                    prop="goodsname"
                    label="商品名称">
            </el-table-column>
            <el-table-column
                    prop="username"
                    label="下单人">
            </el-table-column>
            <el-table-column
                    prop="dprice"
                    label="单价">
            </el-table-column>
            <el-table-column
                    prop="zprice"
                    label="总价">
            </el-table-column>
            <el-table-column
                    prop="tb_quantity"
                    label="购买数量">
            </el-table-column>
            <el-table-column
                    prop="order_date"
                    label="下单时间">
            </el-table-column>
        </el-table>
        <!--        分页插件-->
        <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page.sync=this.SearchForm.currentPage
                :page-sizes="pageSizes"
                :page-size=this.SearchForm.pageSize
                layout="total, sizes, prev, pager, next, jumper"
                :total="total">
        </el-pagination>
    </div>
</template>

<script>
    export default {
        name: "hourGuanLi",
        data(){
          return{
              tableData:[],
              SearchForm:{
                  //当前页码
                  currentPage: 1,
                  //每也显示的个数
                  pageSize: 3,
                  beginTime:"",
                  endTime:"",
                  goodsname:""
              },
              pageSizes:[1,3,5,7],
              //总条数
              total:0,
          }
        },
        created() {
            this.initTable()
        },
        methods:{
            initTable(){
                 this.$http.post("/order/orderShop/orderShop",this.SearchForm).then(result=>{
                     this.tableData = result.data.data.records
                     console.log(result)
                     this.total = result.data.data.total;
                 })
            },
            //分页相关函数
            handleSizeChange(val) {
                this.SearchForm.pageSize = val
                this.initTable();
            },
            handleCurrentChange(val) {
                this.SearchForm.currentPage = val
                this.initTable()
            },
        }
    }
</script>

<style scoped>

</style>